<script>
    import { ChanInfo } from '../service.js';

    let el;
    let notification = "";
    let status = "";

    ChanInfo.subscribe(signal => {
        if (!signal) return
        Show(signal.status,signal.msg);
    });

    export function Show(state,msg){
        status = state ? "is-success" : "is-danger";
        notification = state ? msg : "失败:" + msg;
        el.style.display = "block";
        setTimeout(Display,3000);
    }
    function Display(){
        el.style.display = "none";
    }
</script>

<div class="notification is-link" bind:this={el}>
    {notification}
</div>

<style>
    .notification {
        display: none;
        position: absolute;
        width: 100vw;
        text-align: center;
        font-size: 18px;
    }
</style>
